#include "ChooseScene.h"
#include "config.h"

ChooseScene::ChooseScene()
{
    ButtonSize = 160;
    QPushButton *button[3] = {&choose_miner, &choose_belt, &choose_cutter};
    QString style[] = {
        "QPushButton{image: url(:/res/miner_button.png)}",
        "QPushButton{image: url(:/res/belt_button.png)}",
        "QPushButton{image: url(:/res/cutter_button.png)}"
    };
    for (int i = 0; i < 3; ++i)
    {
        button[i]->setParent(this);
        button[i]->setFixedSize(ButtonSize, ButtonSize);
        button[i]->setStyleSheet(style[i]);
    }
}

void ChooseScene::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setFont(QFont("楷体", 35, QFont::Bold));
    painter.drawText(WidgetInfo::WIDGET_WIDTH / 2 - 530, (WidgetInfo::WIDGET_HEIGHT - ButtonSize) / 2 - 35, QString("恭喜通关！请选择希望在下一关升级速度的建筑："));

    QPushButton *button[3] = {&choose_miner, &choose_belt, &choose_cutter};
    for (int i = 0; i < 3; ++i)
    {
        button[i]->move(180 * (i + 1) + ButtonSize * i, (WidgetInfo::WIDGET_HEIGHT - ButtonSize) / 2);
        button[i]->show();
    }
}
